package com.mine.frame.mylandemo.mvp.presenter

import com.mine.frame.common.base.BasePresenter
import com.mine.frame.mylandemo.entity.forick.ControlBean
import com.mine.frame.mylandemo.mvp.iview.ILiftCabinet
import com.third.device.mg.serialport.MGSerialPort
import com.third.device.mg.serialport.utils.toUInt16H

/**
 * @Date 2022/2/12
 * Description:
 */
class LiftCabinetPresenter(mView: ILiftCabinet) : BasePresenter<ILiftCabinet>(mView) {
    /**
     * 创建控制数据
     */
    fun createControlData() {
        val list = mutableListOf<ControlBean>()
        list.add(ControlBean(true, "捷昌-厨电家居-升降吊柜"))

        val queryProtocolVersion = ControlBean(false, "查询协议版本")
        queryProtocolVersion.command = MGSerialPort.instance.getJieCang().liftCabinet().queryProtocolVersion()
        list.add(queryProtocolVersion)

        val querySoftwareVersion = ControlBean(false, "查询软件版本")
        querySoftwareVersion.command = MGSerialPort.instance.getJieCang().liftCabinet().querySoftwareVersion()
        list.add(querySoftwareVersion)


        val control01 = ControlBean(false, "续动上运行")
        control01.command = MGSerialPort.instance.getJieCang().liftCabinet().controlDevice(0x01)
        list.add(control01)

        val control02 = ControlBean(false, "续动下运行")
        control02.command = MGSerialPort.instance.getJieCang().liftCabinet().controlDevice(0x02)
        list.add(control02)

        val control03 = ControlBean(false, "点动上运行")
        control03.command = MGSerialPort.instance.getJieCang().liftCabinet().controlDevice(0x03)
        list.add(control03)

        val control04 = ControlBean(false, "点动下运行")
        control04.command = MGSerialPort.instance.getJieCang().liftCabinet().controlDevice(0x04)
        list.add(control04)

        val control05 = ControlBean(false, "正常停止")
        control05.command = MGSerialPort.instance.getJieCang().liftCabinet().controlDevice(0x05)
        list.add(control05)

        val control06 = ControlBean(false, "急停")
        control06.command = MGSerialPort.instance.getJieCang().liftCabinet().controlDevice(0x06)
        list.add(control06)

        val control07 = ControlBean(false, "运行至记忆1")
        control07.command = MGSerialPort.instance.getJieCang().liftCabinet().controlDevice(0x07)
        list.add(control07)

        val control08 = ControlBean(false, "运行至记忆2")
        control08.command = MGSerialPort.instance.getJieCang().liftCabinet().controlDevice(0x08)
        list.add(control08)

        val control09 = ControlBean(false, "运行至记忆3")
        control09.command = MGSerialPort.instance.getJieCang().liftCabinet().controlDevice(0x09)
        list.add(control09)

        val control0A = ControlBean(false, "运行至记忆4")
        control0A.command = MGSerialPort.instance.getJieCang().liftCabinet().controlDevice(0x0A)
        list.add(control0A)


        val getH = ControlBean(false, "获取设备当前高度")
        getH.command = MGSerialPort.instance.getJieCang().liftCabinet().queryHeight()
        list.add(getH)


        val runH200 = ControlBean(false, "运行到200mm")
        runH200.command = MGSerialPort.instance.getJieCang().liftCabinet().runHeight(200)
        list.add(runH200)

        val runH500 = ControlBean(false, "运行到500mm")
        runH500.command = MGSerialPort.instance.getJieCang().liftCabinet().runHeight(500)
        list.add(runH500)

        val func01 = ControlBean(false, "设置上限")
        func01.command = MGSerialPort.instance.getJieCang().liftCabinet().setFunction(0x01)
        list.add(func01)

        val func02 = ControlBean(false, "设置下限")
        func02.command = MGSerialPort.instance.getJieCang().liftCabinet().setFunction(0x02)
        list.add(func02)

        val func03 = ControlBean(false, "设置记忆1")
        func03.command = MGSerialPort.instance.getJieCang().liftCabinet().setFunction(0x03)
        list.add(func03)

        val func04 = ControlBean(false, "设置记忆2")
        func04.command = MGSerialPort.instance.getJieCang().liftCabinet().setFunction(0x04)
        list.add(func04)

        val func05 = ControlBean(false, "设置记忆3")
        func05.command = MGSerialPort.instance.getJieCang().liftCabinet().setFunction(0x05)
        list.add(func05)

        val func06 = ControlBean(false, "设置记忆4")
        func06.command = MGSerialPort.instance.getJieCang().liftCabinet().setFunction(0x06)
        list.add(func06)

        val func07 = ControlBean(false, "取消上限")
        func07.command = MGSerialPort.instance.getJieCang().liftCabinet().setFunction(0x07)
        list.add(func07)

        val func08 = ControlBean(false, "取消下限")
        func08.command = MGSerialPort.instance.getJieCang().liftCabinet().setFunction(0x08)
        list.add(func08)

        val func09 = ControlBean(false, "取消记忆1")
        func09.command = MGSerialPort.instance.getJieCang().liftCabinet().setFunction(0x09)
        list.add(func09)

        val func0a = ControlBean(false, "取消记忆2")
        func0a.command = MGSerialPort.instance.getJieCang().liftCabinet().setFunction(0x0a)
        list.add(func0a)

        val func0b = ControlBean(false, "取消记忆3")
        func0b.command = MGSerialPort.instance.getJieCang().liftCabinet().setFunction(0x0b)
        list.add(func0b)

        val func0c = ControlBean(false, "取消记忆4")
        func0c.command = MGSerialPort.instance.getJieCang().liftCabinet().setFunction(0x0c)
        list.add(func0c)

        val func0d = ControlBean(false, "取消记忆所有记忆位置")
        func0d.command = MGSerialPort.instance.getJieCang().liftCabinet().setFunction(0x0d)
        list.add(func0d)



        mIView.initControlList(list)
    }



}